package com.ttg.common.utils;

import com.ttg.common.component.LoginCrypto;
import com.ttg.common.component.impl.GmLoginCryptoUtils;
import com.ttg.common.component.impl.OldLoginCryptoUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * @ClassName JmSwitch
 * @Description 加密工具类选择器
 * @Author sss
 * @Date 2022/6/7
 * @Version 1.0
 **/
public class JmSwitch {
    //Symmetric
    // asymmetric


    public static LoginCrypto getLoginCrypto(String signType) {

        LoginCrypto rs = null;
        if (StringUtils.isBlank(signType)) {
            rs = SpringUtils.getBean(OldLoginCryptoUtils.class);
        } else if ("GM".equals(signType) || "SM2".equals(signType)) {
            rs = SpringUtils.getBean(GmLoginCryptoUtils.class);
        }  else {
            rs = SpringUtils.getBean(OldLoginCryptoUtils.class);
        }
        return rs;
    }
    /*
     *//**
     * 根据sign_type自动选择对称加密算法
     *
     * @param signType 类型
     * @return
     *//*
    public static GeneralSecurity getSymmetricSecurityUtils(String signType) {
        GeneralSecurity rs = null;
        switch (signType) {
            case "GM":
                rs = SpringUtils.getBean(GmSecurity.class);
                break;
            default:
                rs = SpringUtils.getBean(OldSecurity.class);
                break;
        }
        return rs;
    }

     *//**
     * 根据sign_type自动选择非对称加密算法
     *
     * @param signType 类型
     * @return
     *//*
    public static GeneralSecurity getAsymmetricSecurityUtils(String signType) {
        GeneralSecurity rs = null;
        switch (signType) {
            case "GM":
                rs = SpringUtils.getBean(Sm2Security.class);
                break;
            default:
                rs = SpringUtils.getBean(RsaSecurity.class);
                break;
        }
        return rs;
    }

     *//**
     * UserTokenInfo 信息的加密算法
     *
     * @return
     *//*
    public static GeneralSecurity getTokenSecurityUtils() {
        return SpringUtils.getBean(TokenGmSecurity.class);
    } */
}
